import { useState, useEffect } from "react";
import { Image } from "react-vant";
import { Swiper } from "antd-mobile";
import "../css/Slideshow.less";
import instance from "../pages/utils/https";
export default function Slideshow() {
  const [images, setImages] = useState([]);

  //  获取轮播图数据
  const getCarousel = async () => {
    const res = await instance.get("/homePage/getCarousel");
    setImages(res.data);
  };
  useEffect(() => {
    getCarousel();
  }, []);

  return (
    <div className="demo-swiper">
      <a href="https://shop1655815350.v.weidian.com/?userid=1655815350&distributorid=1866412472&share_relation=c21c053587e71501_1866412472_1&wfr=h5direct_wxh5">
        <Swiper autoplay loop={true}>
          {images.map((item: any) => (
            <Swiper.Item key={item._id} className="rv-swiper">
              <Image lazyload src={item.imgPath} className="img" />
            </Swiper.Item>
          ))}
        </Swiper>
      </a>
    </div>
  );
}
